Skip to content

ci: skip image push in forked repositories#2805

Open
areebahmeddd wants to merge 2 commits into
docker:mainfrom
areebahmeddd:fix/ci-skip
Open

ci: skip image push in forked repositories#2805
areebahmeddd wants to merge 2 commits into
docker:mainfrom
areebahmeddd:fix/ci-skip

Conversation

@areebahmeddd
Copy link
Copy Markdown
Contributor

got notification about failing build job in my forked repo

image image

this should be skipped while other jobs run as normal

@areebahmeddd areebahmeddd requested a review from a team as a code owner May 15, 2026 20:41
Comment thread .github/workflows/ci.yml Outdated

build-and-push-image:
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && github.repository == 'docker/docker-agent'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (consider): Hardcoding the repo slug docker/docker-agent works, but couples this guard to the repository name — a future rename or transfer would silently disable image pushes from main/tags.

A more intent-revealing alternative is to gate on whether the workflow is running in a fork:

if: github.event_name != 'pull_request' && !github.event.repository.fork

github.event.repository.fork is false for the upstream and true for any fork, which is exactly the property we care about ("don't try to push from forks"). It's also rename/transfer-proof and matches the language of the PR title ("skip image push in forked repositories").

Either approach is fine — happy to merge as-is if you prefer the explicit allow-list form, but worth a thought.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. didn’t know github events had a property like that. your suggestion is much cleaner 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants